<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <div id="app">
            <input type="text" v-focus @focus="handleFocus" />
        </div>
        <input type="text" placeholder="请输入你的昵称" id="inp" />
        <script src="../vue.js"></script>
        <script>
            // inp.focus();
            inp.onfocus = function () {
                console.log('我获得焦点了');
            };
            new Vue({
                el: '#app',
                directives: {
                    // focus是指令的名字
                    /*
                       li {
                            _innerHTML: '你好,
                            _innerText: '你好',
                            _style: {
                                _width: '100px',
                                _height: '200px',
                            },
                            _onclick: null,
                        }
                    */
                    focus: {
                        // inserted是函数
                        inserted(el, binding, vnode) {
                            console.log(el);
                            console.log(binding);
                            console.log(vnode);
                            el.focus();
                        },
                    },
                },
                methods: {
                    handleFocus() {},
                },
            });
        </script>
    </body>
</html>
